#include <iostream>
#include <string.h>
#include <string>

using namespace std;

/* Find if characters in pattern occurs in name in the same order even if not
 * consecutively
 */
bool match(const char *name, const char *pattern)
{
	int i = 0, j = 0;
	int name_len = strlen(name);
	int pat_len = strlen(pattern);

	for (i = 0; i < name_len; i++) {
		if (name[i] == pattern[j])
			j++;

		if (j == pat_len)
			return true;
	}

	return false;
}

int main(void)
{
	string name = "some_file.cc";
	string pattern = "o_l.cc";

	cout << "Match: " << match(name.c_str(), pattern.c_str()) << endl;

	return 0;
}

